<?php
/**
 * @file $HeadURL: imagecollectivetag.php $
 * @author $Author: DongJC (dongjianchang@haibao.com) $
 * @date $Date: 2015-5-4 ����4:54:42 $
 * @brief 
 */
namespace haibao\cms\data\imagecollective;


class ImageCollectiveTag extends \haibao\cms\data\BaseMysql{
	
	public function __construct(){
		parent::__construct('\haibao\cms\model\data\imagecollective\ImageCollectiveTag');
	}
	
	public function getTagByImageCollectiveId($ids){
		
	}

	public function updateTagTree($tagTreeArr){
		$whenStr = $inStr =  '';
		$sqlArr = array();
		foreach($tagTreeArr as $key=>$value){
			$whenStr .= " WHEN %s THEN %s ";
			$inStr .= "%s,";
			$sqlArr[] = $key;
			$sqlArr[] = $value;
		}
		$sql = "UPDATE ImageCollectiveTag
    				SET TagTree = CASE TagId".
			$whenStr
			."END
				WHERE TagId IN (".trim($inStr,',').")";

		$sqlArr = array_merge($sqlArr,array_keys($tagTreeArr));
		$this->query($sql,$sqlArr);
	}
	
}
